/**
 * PackageDir: org.liu.database
 * FileName: DbConn.java
 * CreateDate: 2010-3-16 下午02:30:36
 */
package info.javafans.cdn.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class JdbcConn implements DbConn{
	protected static Logger logger = Logger.getLogger(JdbcConn.class);
	
	public Connection getConnection(Properties prop) {
		Connection conn = null;
		try {
			Class.forName(prop.getProperty("drivername"));
			String url = prop.getProperty("url");
			String username = prop.getProperty("username");
			String password = prop.getProperty("password");
			conn = DriverManager.getConnection(url, username, password);
		} catch (ClassNotFoundException e) {
			logger.error("没有找到驱动" + e.getMessage());
		} catch (SQLException e) {
			logger.error("获取数据库连接出错："+e.getMessage());
		}
		return conn;
	}

}
